package com.sand.controller;

import com.sand.dto.Owner.MerchantOrOwner;
import com.sand.dto.merchant.ContentUpdate;
import com.sand.dto.merchant.ContractAdd;
import com.sand.dto.merchant.StageDelete;
import com.sand.entity.conclude.stage;
import com.sand.result.ResponseResult;
import com.sand.service.StageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/stage")
public class StageController {

    @Autowired
    private StageService stageService;


    /**
     * 添加合同预购
     */
    @PostMapping("/add")
    private ResponseResult<Integer> add(@RequestBody stage stage){
        Integer i = stageService.add(stage);
        return new ResponseResult<Integer>().ok(i);
    }

    /**
     * 修改合同预狗
     */
    @PostMapping("/update")
    private ResponseResult<Integer> upd(@RequestBody ContentUpdate contentUpdate){
        Integer i =  stageService.upd(contentUpdate);
        return new ResponseResult<Integer>().ok(i);
    }

    /**
     * 删除预购
     */
    @PostMapping("/down")
    private ResponseResult<Integer> down(@RequestBody StageDelete stageDelete) {
        Integer i = stageService.down(stageDelete);
        return new ResponseResult<Integer>().ok(i);
    }

    /**
     * 查询所有预购
     */
    @PostMapping("/list")
    private ResponseResult<List<stage>> all(@RequestBody MerchantOrOwner merchantOrOwner){
        List<stage> list = stageService.all(merchantOrOwner);
        return new ResponseResult<List<stage>>().ok(list);
    }



}
